#include "Button.h"
#include "Headers.h"

Button::Button(std::string filename, int xIn, int yIn) :
m_rTexture(txtrMgr.get(filename))
{
	m_sprite.setTexture(m_rTexture);
	m_sprite.setPosition(xIn, yIn);
}

void Button::draw(sf::RenderWindow& window)
{
	window.draw(m_sprite);
}

void Button::move(float x, float y)
{
	m_sprite.move(x, y);
}

bool Button::isClicked(sf::Vector2i position)
{
	return m_sprite.getGlobalBounds().contains(float(position.x), float(position.y));
}

bool Button::isHighlighted(sf::Vector2i position)
{
	if (m_sprite.getGlobalBounds().contains(float(position.x), float(position.y)))
	{
		m_sprite.setColor(sf::Color::Green);
		return true;
	}
	else
	{
		m_sprite.setColor(sf::Color::White);
		return false;
	}
}

void Button::forceHighlight()
{

}